let mix = require('laravel-mix');

// if (!Mix.isUsing('hmr')) {
//    mix.extract(['vue', 'axios'])
// }

// 本块代码用于解决在 windows 环境下的问题
// 如果使用非 windows 系统可删除
// 参考 Issue https://github.com/JeffreyWay/laravel-mix/issues/1483#issuecomment-366685986
Mix.listen('configReady', (webpackConfig) => {
   if (Mix.isUsing('hmr')) {
      // Remove leading '/' from entry keys
      webpackConfig.entry = Object.keys(webpackConfig.entry).
        reduce((entries, entry) => {
           entries[entry.replace(/^\//, '')] = webpackConfig.entry[entry]
           return entries
        }, {})
      // Remove leading '/' from ExtractTextPlugin instances
      webpackConfig.plugins.forEach((plugin) => {
         if (plugin.constructor.name === 'ExtractTextPlugin') {
            plugin.filename = plugin.filename.replace(/^\//, '')
         }
      })
   }
})

mix.webpackConfig({
   devServer: {
      host: "www.qing.ren"
   }
});
/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */
mix//.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css')
   .js('resources/assets/js/myblog.js', 'public/js');

// Selcetize 暂不支持 Bootstrap 4
mix.combine([
   'node_modules/selectize/dist/css/selectize.css',
   'node_modules/selectize/dist/selectize.bootstrap3.css'
], 'public/css/selectize.default.css');

mix.combine([
   'node_modules/pickadate/lib/compressed/themes/default.css',
   'node_modules/pickadate/lib/compressed/themes/default.date.css',
   'node_modules/pickadate/lib/compressed/themes/default.time.css'
], 'public/css/pickadate.min.css');

mix.copy('node_modules/selectize/dist/js/standalone/selectize.min.js', 'public/js/selectize.min.js');

mix.combine([
   'node_modules/pickadate/lib/compressed/picker.js',
   'node_modules/pickadate/lib/compressed/picker.date.js',
   'node_modules/pickadate/lib/compressed/picker.time.js'
], 'public/js/pickadate.min.js')
